//
//  BaseDataModel.h
//  ShowTimeApp
//
//  Created by Ruby on 10/24/11.
//  Class BaseDataModel chua cac instance va method truy xuat data tu DataModel
//

#import <Foundation/Foundation.h>
@interface BaseDataModel : NSObject {
    NSManagedObjectContext *managedObjectContext;
    NSManagedObjectModel *managedObjectModel;
    NSPersistentStoreCoordinator *persistentStoreCoordinator;
    NSFetchedResultsController *fetchResultController;
}
@property (nonatomic,retain) NSManagedObjectContext *managedObjectContext;
@property (nonatomic,retain) NSManagedObjectModel *managedObjectModel;
@property (nonatomic,retain) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic,retain) NSFetchedResultsController *fetchResultController;

//Constructor
- (id)initBaseDataModel;
- (void) initCoreData;

//------------ implement
//Lay toan bo ds object theo entityName va dk, data tra ve luu vao fetchResultController.fetchedObjects
- (void)fetchObjects:(NSString*)entityName sortBy:(NSSortDescriptor*) sortDescriptor;
//Lay ds object theo entityName va dk, data tra ve luu vao fetchResultController.fetchedObjects
- (void)fetchObjects:(NSString*)entityName sortBy:(NSSortDescriptor*) sortDescriptor byPredicate:(NSPredicate*)predicate;
//Lay chi tiet object theo dk
- (NSManagedObject*) fetchObject:(NSString*)entityName byPredicate:(NSPredicate*)predicate;
- (void)removeObjects;
- (BOOL)saveContent:(NSError*) error;
- (NSURL *)applicationDocumentsDirectory;
@end
